---
image: /generated/articles-docs-get-audio-duration-in-seconds.png
title: getAudioDurationInSeconds()
id: get-audio-duration-in-seconds
crumb: '@remotion/media-utils'
---

:::warning Deprecated
This function has been deprecated. Use [`parseMedia()`](/docs/media-parser/parse-media) instead, which is faster and supports more formats.
:::

_Part of the `@remotion/media-utils` package of helper functions._

_Previously called `getAudioDuration()`._

Gets the duration in seconds of an audio source. Remotion will create an invisible `<audio>` tag, load the audio and return the duration.

## Arguments

### `src`

A string pointing to an audio asset

## Return value

`Promise<number>` - the duration of the audio file.

## Example

```tsx twoslash
import {useCallback, useEffect} from 'react';
import {staticFile} from 'remotion';
// ---cut---
import {getAudioDurationInSeconds} from '@remotion/media-utils';
import music from './music.mp3';

const MyComp: React.FC = () => {
  const getDuration = useCallback(async () => {
    const publicFile = await getAudioDurationInSeconds(staticFile('voiceover.wav')); // 33.221
    const imported = await getAudioDurationInSeconds(music); // 127.452
    const remote = await getAudioDurationInSeconds('https://example.com/remote-audio.aac'); // 50.24
  }, []);

  useEffect(() => {
    getDuration();
  }, []);

  return null;
};
```

## See also

- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/media-utils/src/get-audio-duration-in-seconds.ts)
